package pers.cz.jefconfig.tools;

/**
 * @program: netDisc  使用引用传递的方式实现不可变类的传递：例如int类型的传递
 * @description: Holder
 * @author: Cheng Zhi
 * @create: 2020-12-05 13:40
 **/
public class Holder<T> implements IHolder {

    private T value;
    private IHolder pipeHolder;

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        this.value = value;
    }

    public Holder(T value) {
        this.value = value;
    }

    public Holder() {

    }
    @Override
    public String toString() {
        return "Holder{" +
                "value=" + value +
                ", pipeHolder=" + pipeHolder +
                '}';
    }

    @Override
    public Object get() {
        return null;
    }

    @Override
    public void set(Object obj) {

    }

    /**
     * 测试方法
     * @param args
     */
    public static void main(String[] args) {
        // doing();
        String name  = "cz";
        Holder holder = new Holder(name);
        change(holder);
        System.out.println(holder.getValue());

        Integer a = 5;
        Holder holder1 = new Holder(a);
        changeInt(holder1);
        System.out.println(holder1.getValue());

    }

    private static void changeInt(Holder holder) {
        Integer a = (Integer) holder.getValue();
        holder.setValue( a+1);
    }
    private static void change(Holder holder) {
        holder.setValue("cz666");

    }
}
